/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode removeElements(ListNode head, int val) {
        ListNode current=new ListNode(0);
        current.next=head;
        ListNode xin=current;
        while(xin.next!=null)
        {
            if(xin.next.val==val)
            {
                xin.next=xin.next.next;
            }
            else{
                xin=xin.next;
            }
        }
        return current.next;
    }
}


